module teapo.storage.attached.indexedDB { export class StorageAccess implements attached.StorageAccess { constructor(private _db: IDBDatabase) { byFullPath: PropertiesByFullPath,
callback: (error: Error) => void): void { var transaction = this._db.transaction(['files', 'metadata'], 'readwrite');
transaction.onerror = (errorEvent) => callback(wrapErrorEvent(errorEvent, 'update: transaction'));
var filesStore = transaction.objectStore('files'); var outstandingRequests = 1;
function oneError(errorEvent: ErrorEvent, moreDescription) { if (!outstandingRequests) return;
callback(wrapErrorEvent(errorEvent, moreDescription));
function oneCompleted() { if (!outstandingRequests) return;
if (!outstandingRequests)
for (var fullPath in byFullPath) if (byFullPath.hasOwnProperty(fullPath)) { var pbag = byFullPath[fullPath];
var deleteRequest = filesStore['delete'](fullPath);
deleteRequest.onerror = (errorEvent) => oneError(errorEvent, 'update: objectStore(files).delete(' + fullPath+')'); deleteRequest.onsuccess = (event) => { var getRequest = filesStore.get(fullPath);
getRequest.onerror = (errorEvent) => oneError(errorEvent, 'update: objectStore(files).delete(' + fullPath + ')'); getRequest.onsuccess = (event) => { var fileData: FileData = getRequest.result || { path: fullPath, properties: {} }; var properties = fileData.properties || (fileData.properties = {}); for (var p in pbag) if (pbag.hasOwnProperty(p)) { if (v === null || typeof v === 'undefined')
var putFile = filesStore.put(fileData);
getRequest.onerror = (errorEvent) => oneError(errorEvent, 'update: objectStore(files).put(' + fullPath + ')'); putFile.onsuccess = (event) =>
oneError(errorEvent, 'update: _updateEditedUTC');
callback: (error: Error, properties: { [property: string]: string; }) => void): void {